import request from "./request";

let route = 'http://farmer.handsomesunshine.com';

// 获取收货地址
export function getAddress() {
  return request({
    url:`${route}/api/addresslist`
  })
}

// 添加收货地址
export function addAddres(addres) {
  return request({
    url:`${route}/api/additionaddress`,
    method:'POST',
    data:{
      address:addres
    }
  })
}

// 修改地址
export function changeAddress(addres) {
  return request({
    url:`${route}/api/updateaddress`,
    method:'POST',
    data:{
      address:addres
    }
  })
}

// 删除地址
export function deleteAddress(id) {
  return request({
    url:`${route}/api/deleteaddress`,
    method:'POST',
    data:{id}
  })
}

// 确认订单渲染
export function getOrder(goodsInfo) {
  return request({
    url:`${route}/api/orderdetail`,
    method:'POST',
    data:{goodsInfo}
  })
}

// 登录
export function login(code,userInfo) {
  return request({
    url:`${route}/api/login`,
    method:'POST',
    data:{ code,userInfo }
  })
}

// 验证token
export function isToken() {
  return request({
    url:`${route}/api/checktoken`
  })
}

// 支付
export function payment(orderInfo) {
  return request({
    url:`${route}/api/addorder`,
    method:'POST',
    data:{ orderInfo }
  })
}

// 通过经纬度 获取地理位置
export function getLocation(latitude,longitude) {
  return request({
    url:`https://api.map.baidu.com/geocoder/v2/?location=${latitude},${longitude}&output=json&ak=WEc8RlPXzSifaq9RHxE1WW7lRKgbid6Y`
  })
}